/*
 * Copyright 2012-2019 the original author or authors.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      https://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package org.springframework.boot.web.servlet;

import javax.servlet.ServletContainerInitializer;
import javax.servlet.ServletContext;
import javax.servlet.ServletException;

import org.springframework.web.SpringServletContainerInitializer;
import org.springframework.web.WebApplicationInitializer;

/**
 * 用于以编程方式配置 Servlet 3.0+ {@link ServletContext context} 的接口。
 * 与 {@link WebApplicationInitializer} 不同，实现此接口（且未实现 {@link WebApplicationInitializer}）的类
 * <b>不会</b> 被 {@link SpringServletContainerInitializer} 检测到，因此不会被 Servlet 容器自动引导启动。
 * <p>
 * 此接口的设计方式类似于 {@link ServletContainerInitializer}，
 * 但其生命周期由 Spring 管理，而不是由 Servlet 容器管理。
 * <p>
 * 配置示例可参考 {@link WebApplicationInitializer}。
 *
 * @author Phillip Webb
 * @since 1.4.0
 * @see WebApplicationInitializer
 */
@FunctionalInterface
public interface ServletContextInitializer {

	/**
	 * 使用所需的 servlet、filter、listener、context-param 和属性对给定的 {@link ServletContext} 进行初始化配置。
	 * @param servletContext 要初始化的 {@code ServletContext}
	 * @throws ServletException 如果对 {@code ServletContext} 的调用抛出了 {@code ServletException}
	 */
	void onStartup(ServletContext servletContext) throws ServletException;

}
